﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true"
    CodeBehind="ManageGalleries.aspx.cs" Inherits="Photography.Admin.ManageGalleries" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:LinqDataSource ID="CategoriesDataSource" runat="server" ContextTypeName="Photography.App_Data.PhotographyDataContext" OnSelecting="GetCategories">
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="GalleriesDataSource" runat="server" ContextTypeName="Photography.App_Data.PhotographyDataContext"
        OnSelecting="GetGalleries" />
    <asp:LinqDataSource ID="PhotosDataSource" runat="server" ContextTypeName="Photography.App_Data.PhotographyDataContext"
        OnSelecting="GetPhotos" />
    <div>
        <asp:Label runat="server" ID="lblNotification" Style="color: #00CC00; font-weight: 700"></asp:Label></div>
    <table border="1">
        <tr>
            <td style="border: 0">
                Galleries
            </td>
            <td><asp:DropDownList runat="server" ID="cboCategory" Width="326px" DataSourceID="CategoriesDataSource" DataTextField="Name" DataValueField="ID" AutoPostBack="True" OnSelectedIndexChanged="cboCategory_SelectedIndexChanged" /></td>
            <asp:Repeater ID="Repeater1" runat="server" DataSourceID="GalleriesDataSource">
                <ItemTemplate>
                    <td <%# (Master.GalleryId.HasValue && Master.GalleryId.Value.Equals(DataBinder.Eval(Container.DataItem, "ID")))? "bgcolor=\"#99ccff\"" : "" %>>
                        <a href="ManageGalleries.aspx?cat=<%#Master.CategoryId %>&gal=<%# DataBinder.Eval(Container.DataItem, "ID") %>">
                            <%# DataBinder.Eval(Container.DataItem, "Name") %>
                        </a>
                    </td>
                </ItemTemplate>
            </asp:Repeater>
            <td>
                <asp:Button runat="server" ID="btnAddGallery" Text="Add New Gallery" 
                    onclick="btnAddGallery_Click" />
            </td>
        </tr>
    </table>
    <p>
    </p>
    <p>
        <% if (Master.GalleryId.HasValue)
           { %>
        <asp:Button runat="server" ID="btnAddPhoto" Text="Add New Photo" OnClick="btnAddPhoto_Click" />
        <asp:Button runat="server" ID="btnEditGallery" Text="Edit Gallery" OnClick="btnEditGallery_Click" /><%} %></p>
    <asp:GridView ID="grdPhotos" runat="server" AutoGenerateColumns="False" DataSourceID="PhotosDataSource"
        OnRowCommand="grdPhotos_OnRowCommand" DataKeyNames="ID" OnRowCreated="grdPhotos_RowCreated">
        <Columns>
            <asp:BoundField DataField="Title" HeaderText="Title" />
            <asp:ImageField DataImageUrlField="Location" HeaderText="Thumbnail" DataAlternateTextField="Title"
                ControlStyle-Height="40">
                <ControlStyle Height="40px"></ControlStyle>
            </asp:ImageField>
            <asp:BoundField DataField="Description" HeaderText="Description" />
            <asp:BoundField DataField="Location" HeaderText="URL" />
            <asp:ButtonField Text="Delete" CommandName="DeletePhoto" />
            <asp:ButtonField Text="Edit" CommandName="EditPhoto" />
            <asp:ButtonField Text="Move Up" CommandName="MoveUp" />
            <asp:ButtonField Text="Move Down" CommandName="MoveDown" />
        </Columns>
    </asp:GridView>
</asp:Content>
